<template>
  <!-- 图表必须给宽高 否则实现不了 -->
  <div ref="myDiv" class="radar-echart">leidatu</div>
</template>

<script>
// import * as echarts from 'echarts'
// 引入echarts主模块
import * as echarts from 'echarts/core'
// 引入雷达图图表
import { RadarChart } from 'echarts/charts'
import { LegendComponent } from 'echarts/components'
// 引入提示框，标题，直角坐标系，数据集，内置数据转换器组件，组件后缀都为 Component
import {
  TitleComponent,
  TooltipComponent,
  GridComponent,
  DatasetComponent,
  TransformComponent
} from 'echarts/components'
// 标签自动布局，全局过渡动画等特性
import { LabelLayout, UniversalTransition } from 'echarts/features'
// 引入 Canvas 渲染器，注意引入 CanvasRenderer 或者 SVGRenderer 是必须的一步
import { CanvasRenderer } from 'echarts/renderers'
// 注册必须的组件
echarts.use([
  TitleComponent,
  TooltipComponent,
  GridComponent,
  DatasetComponent,
  TransformComponent,
  RadarChart,
  LabelLayout,
  UniversalTransition,
  LegendComponent,
  CanvasRenderer
])
// var myChart = echarts.init(document.getElementById('main'))
export default {
  name: '',
  components: {},
  props: {},
  data() {
    return {

    }
  },

  computed: {},
  watch: {},
  created() {
    // 实例创建完毕 页面未渲染
  },
  mounted() {
    const myChart = echarts.init(this.$refs.myDiv) // 得到图标实例
    // 绘制图表
    const option = {
      title: {
        text: 'Basic Radar Chart'
      },
      legend: {
        data: ['Allocated Budget', 'Actual Spending']
      },
      radar: {
        // shape: 'circle',
        // 每个区域的最高值
        indicator: [
          { name: '工作效率', max: 100 },
          { name: '考勤', max: 100 },
          { name: '积极程度', max: 100 },
          { name: '帮助同事', max: 100 },
          { name: '自主学习', max: 100 },
          { name: '正确率', max: 100 }
        ]
      },
      series: [
        {
          name: 'Budget vs spending',
          type: 'radar',
          data: [
            {
              value: [42, 30, 20, 35, 50, 18],
              name: '张三'
            },
            {
              value: [50, 14, 28, 26, 42, 21],
              name: '李四'
            }
          ]
        }
      ]
    }
    myChart.setOption(option)
  },
  methods: {}
}
</script>
<style lang='css' scoped>
.radar-echart {
  width: 600px;
  height: 400px;
}
</style>